#pragma once

class ButtonListener;

class Button : public ZeEngine::GUIObject
{
private:
    enum ButtonState
    {
        ePressed,
        eReleased,
    };

public:
    Button(const std::string& buttonUp, const std::string& buttonDown, const std::string& buttonHover, const Vector2D<float>& position);

    ~Button();

    virtual bool Update() override;
    virtual void Render(SDL_Renderer& renderer) override;

    virtual bool OnMouseButtonPressed(const Vector2D<s32>& absolute, s32 button) override;
    virtual bool OnMouseButtonReleased(const Vector2D<s32>& absolute, s32 button) override;
    virtual void OnMouseButtonUp(const Vector2D<s32>& absolute, s32 button) override;

    virtual void OnMouseIn() override;
    virtual void OnMouseOver() override;
    virtual void OnMouseOut() override;

    void SetListener(ButtonListener* pListener);

private:
    void ChangeState(ButtonState newState);

private:
    SDLTexture* m_pButtonUp;
    SDLTexture* m_pButtonDown;
    SDLTexture* m_pButtonHover;

    ButtonListener* m_pListener;
    ButtonState     m_state;
    bool            m_isHovering;
};

class ButtonListener
{
public: 
    virtual void OnButtonClicked(u32 id) = 0;
};